import request from '@/utils/request'

// 获取驾驶舱所有有资源权限卡片的状态（样式:0-正常,1-新上线,2-UAT）
const queryMenuCornerMarkPcApi = () => {
	return request({
		url: `/portal-server/v1/api/opBuProjectDetail/queryMenuCornerMarkPc`,
		method: 'get'
	})
}

/**
 * 驾驶舱首页--获取时间 商业的 年月日（有时可以不传menuKey）
 */
const queryDataTimeApi = (menuKey) => {
	return request({
		url: `/portal-server/v1/api/project/queryDataTime?menuKey=${menuKey}`,
		method: 'get',
	})
};

/**
 * 根据按钮权限+日期获取项目列表接口
 */
const queryProjectPcApi = (params) => {
	return request({
		url: `/portal-server/v1/api/opBuProjectDetail/queryProjectPc`,
		method: 'post',
		data: params
	})
}

/**
 * 根据按钮权限获取项目列表接口+数据更新日期年月日
 */
 const queryProjectListsApi = (resourceKey) => {
	return request({
		url: `/portal-server/v1/api/opBuProjectDetail/queryProjectLists?resourceKey=${resourceKey}`,
		method: 'get',
	})
}

/**
 * 根据页面权限获取项目列表接口+数据更新日期年月日
 */
 const queryProjectListsByPageKeyApi = (pageKey) => {
	return request({
		url: `/portal-server/v1/api/opBuProjectDetail/queryProjectListsByPageKey?pageKey=${pageKey}`,
		method: 'get',
	})
}

/**
 * 根据biProjectCode获取隐藏的card权限标识
 */
 const queryMenuHidePcApi = (biProjectCode) => {
	return request({
		url: `/portal-server/v1/api/opBuProjectDetail/queryMenuHidePc?biProjectCode=${biProjectCode}`,
		method: 'get',
	})
}

/**
 * 驾驶舱pc--获取项目基本信息
 */
const queryProjectInformationPcApi = (data) => {
	return request({
		url: `/portal-server/v1/api/business/queryProjectInformationPc?biProjectCode=${data.biProjectCode}&projectCode=${data.projectCode}&resourceKey=${data.resourceKey}&templateCode=${data.templateCode}`,
		method: 'get',
	})
};

/**
 * 项目首页--头部基本信息  --  针对商管的
 * @param  biProjectCode  项目code
 * @param  projectCode
 */
const baseInfoApi = ({ biProjectCode, projectCode }) => {
	// const data = {
	// 	biProjectCode,
	// 	projectCode,
	// }
	return request({
		url: `/portal-server/v1/api/business/queryProjectInformation?biProjectCode=${biProjectCode}&projectCode=${projectCode}`,
		method: 'get',
		// data: data
	})
};

const publicBaseInfoApi = ({ biProjectCode, projectCode, menuKey }) => {
	const data = {
		biProjectCode,
		projectCode,
		menuKey,
	}
	return request({
		url: `/portal-server/v1/api/opBuProjectDetail/baseInfo?biProjectCode=${data.biProjectCode}&projectCode=${data.projectCode}&menuKey=${data.menuKey}`,
		method: 'get',
	})
};

// 查询字典表接口
// { dicTypes: ["WIN_BIZ_TYPE_LEVEL_1",'AREA'] }
const queryDict = (params) => {
	return request({
		url: `/v1/api/tDict/query`,
		method: 'post',
		data: params,
		baseURL: process.env.VUE_APP_ZHAOSHANG_API
	})
}

// 级联字典查询
const queryCascadeDict = (parentId) => {
	return request({
		url: `/v1/api/tDict/queryByParent?parentId=${parentId}`,
		method: 'get',
		baseURL: process.env.VUE_APP_ZHAOSHANG_API
	})
}


// 物业的 获取数据更新时间 年月 年
const queryUpdateTimeApi = () => {
	return request({
		url: `/portal-server/v1/api/calculagte/queryUpdateTime`,
		method: 'post',
	})
}

// 商业的 获取数据更新时间 年月
const queryMonthsTimeApi = () => {
	return request({
		url: `/portal-server/v1/api/calculagte/queryMonthsTime`,
		method: 'get',
	})
}

// 物业字典
export const getPropertyDictoryApi = params => {
	return request({
		url: `/property-portal/v1/api/tDict/query`,
		method: 'post',
		data: params
	});
};

// 驾驶舱卡片页 -- 页面分组
export const queryCardPermissionPcApi = (params) => {
	return request({
		url: `/portal-server/v1/api/opBuProjectDetail/queryCardPermissionPc?pageKey=${params.pageKey}&biProjectCode=${params.biProjectCode}`,
		method: 'get',
	});
};

export default {
	queryMenuCornerMarkPcApi,
	queryDataTimeApi,
	queryProjectPcApi,
	queryProjectListsApi,
	queryProjectListsByPageKeyApi,
	queryMenuHidePcApi,
	queryProjectInformationPcApi,
	baseInfoApi,
	publicBaseInfoApi,
	queryDict,
	queryCascadeDict,
	queryUpdateTimeApi,
	queryMonthsTimeApi
}